package com.zhangxu.microservice.employee.web;

import com.zhangxu.microservice.common.utils.AesEncryptUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

@RefreshScope
@SpringBootApplication
@ComponentScan(basePackages = {"com.zhangxu.microservice.employee"})
@MapperScan(basePackages = {"com.zhangxu.microservice.employee.dao.mapper"})
public class EmployeeServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(EmployeeServiceApplication.class, args);
    }

    @Bean
    public CommandLineRunner initAesKey(@Value("${encrypt.aes-key}") String aesKey) {
        return args -> AesEncryptUtils.setKey(aesKey);
    }
}
